package com.fqgj.sentry.policy.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.sentry.policy.dao.PcPolicySetsDao;
import com.fqgj.sentry.policy.entity.PcPolicySetsEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: yujianfu
 * Date: 2017-07-12
 * Time: 09:37:58.137
 */

@Repository
public class PcPolicySetsDaoImpl extends AbstractBaseMapper<PcPolicySetsEntity> implements PcPolicySetsDao {

    @Override
    public List<PcPolicySetsEntity> selectByAppIdsAndPage(Long appId) {
        return getSqlSession().selectList(getStatement("selectByAppIdAndPage"), appId);
    }

    @Override
    public PcPolicySetsEntity selectOneByEventAndApp(Long eventId, Long appId) {
        HashMap<String, Object> param = new HashMap<>();
        param.put("eventId",eventId);
        param.put("appId",appId);
        return getSqlSession().selectOne(getStatement("selectOneByEventAndApp"), param);
    }

    @Override
    public PcPolicySetsEntity selectOneByCode(String code) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        return getSqlSession().selectOne(getStatement("selectOneByCode"), map);
    }

    @Override
    public List<PcPolicySetsEntity> selectByEventId(Long eventId) {
        return getSqlSession().selectList(getStatement("selectByEventId"), eventId);
    }
}